<?php
define('FPDF_FONTPATH', 'font/');
require('./font/fpdf.php');
include("include/config.inc.php");
if(!isset($_SESSION['s_activId']))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{
  $pdf=new FPDF('P','mm','A4');   //Create new pdf file
  $pdf->Open();     //Open file
  $pdf->SetAutoPageBreak(false);  //Disable automatic page break
  
  $pdf->AddPage();  //Add first page
  $yAxis     = 10;
  foreach($_POST['checkedParty'] as $key => $partyId)
  {
  	printData($partyId,$yAxis);
  	$yAxis = $yAxis + 36;
  }
}

function printData($checkedParty,$yAxis)
{
	
	
  $selectParty = "SELECT partyId,partyName,mobile1,mobile2,add1,add2,taluko,dist,city,pin
                        FROM party
                       LEFT JOIN city ON city.cityId = party.cityId
                       WHERE partyId = ".$checkedParty;
  $selectPartyRes = mysql_query($selectParty);
  if($partyRow = mysql_fetch_array($selectPartyRes))
  {
  	global $pdf;
  	$pdf->SetFont('Arial','',13);
    $pdf->SetFont('Arial', '', 10);
    $pdf->SetXY(5,$yAxis);
    $pdf->Cell(200,6,$partyRow['partyName'], 0,0,'L');
    $pdf->SetXY(5,$yAxis+6);
    $pdf->Cell(200,6,$partyRow['add1'],0,0,'L');
    $pdf->SetXY(5,$yAxis+11);
    $pdf->Cell(200,6,$partyRow['add2'],0,0,'L');
    $pdf->SetXY(5,$yAxis+16);
    $pdf->Cell(180,6, "Taluko : ".$partyRow['taluko'],0,0,'L');
    $pdf->SetXY(35,$yAxis+15);
    $pdf->Cell(200,8, "Dist : ".$partyRow['dist'],0,0,'L');
    $pdf->SetXY(5,$yAxis+21);
    $pdf->Cell(200,6, "City : ".$partyRow['city'],0,0,'L');
    $pdf->SetXY(35,$yAxis+21);
    $pdf->Cell(200,6, "Pin : ".$partyRow['pin'],0,0,'L');
    $pdf->SetXY(5,$yAxis+26);
    $pdf->Cell(200,6, "Mobile 1 : ".$partyRow['mobile1'],0,0,'L');
  }
}
$pdf->Output();
?>